package com.cssw.fyzb.busi.api.acct;

import com.cssw.fyzb.busi.api.user.GetUserInfo;
import com.cssw.fyzb.core.model.vo.acct.AcctGlobalVo;
import com.cssw.fyzb.busi.service.acct.AcctService;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * 获取用户钱包信息
 *
 * asa
 */
@Function(description = "获取用户钱包信息", parameters = {
        @Parameter(name = "userId", type = Type.String, description = "用户标识", required = true)
})

@Component
public class AcctInfo implements Action {

    @Autowired
    private AcctService acctService;
    private static final Logger logger = LoggerFactory.getLogger(GetUserInfo.class);
    @Override
    public Response execute(Request request) throws Exception {
        Long userId = request.getLong("userId");

        try {
            AcctGlobalVo acctGlobalVo = acctService.queryAcctGlobal(userId);
           return Response.success().put("data", acctGlobalVo);
//            return Response.success().put("list", acctGlobalVo).put("total", 1).put("count", 3);

        } catch (Exception e) {
            logger.error("", e);
            return Response.fail("操作异常");
        }
    }
}
